package Yichang;

import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Student stu = new Student();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名");
        stu.setName(sc.next());
        while (true) {
            System.out.println("请输入年龄");
            String s = sc.next();
            try {
                int i = Integer.parseInt(s);
                stu.setAge(i);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数");
                continue;
            } catch (AgeOutOfBoundException a) {
                System.out.println(a.toString());
                System.out.println("请输入一个合理的年龄");
                continue;
            }
        }
        System.out.println(stu);

    }
}
